package com.xbongbong.pro.enums.workrecord.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

@Getter
public enum WorkrecordResultEnum {

    REFUSE("enum.workrecordResult.name.refuse","REFUSE"),


    AGREE("enum.workrecordResult.name.agree","AGREE"),


    TERMINATED("enum.workrecordResult.name.terminated","TERMINATED"),


    CANCELED("enum.workrecordResult.name.canceled","CANCELED"),
    ;

    private String name;

    private String alias;

    WorkrecordResultEnum(String name, String alias) {
        this.name = name;
        this.alias = alias;
    }

    /**
     * 根据别名获取配置枚举
     * @param alias 配置别名
     * @return WorkrecordResultEnum
     */
    public static WorkrecordResultEnum getByAlias(String alias) {
        WorkrecordResultEnum[] arr = values();

        for (WorkrecordResultEnum cache : arr) {
            if (alias.equals(cache.getAlias())) {
                return cache;
            }
        }

        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
